import type { GreasyForkElements } from '../../../../../../../../../types/constants/personalization/greasy_fork'
import {
  PAGE_ELEMENTS,
  PROJECT_PREFIX,
  SUPPORTED_PLATFORMS,
} from '../../../../../../../../../types/constants'
import { getElementSelector } from '../../../../../../../../../types/constants/personalization/common'

export class InfoPage {
  elements: GreasyForkElements = PAGE_ELEMENTS[SUPPORTED_PLATFORMS.GREASY_FORK]
  private readonly containerSelector = getElementSelector(this.elements, 'COMMON_CONTAINER')
  private static instance: InfoPage

  /**
   * 获取单例实例
   */
  public static getInstance(): InfoPage {
    if (!InfoPage.instance) {
      InfoPage.instance = new InfoPage()
    }
    return InfoPage.instance
  }

  init(): void {
  }

  getMainStyles(): string {
    if (this.containerSelector.length === 0)
      return ''

    return `
${this.containerSelector} {
  #install-area {
    .install-link, .install-help-link {
      color: white !important;
      
      &:hover {
        color: white !important;
        box-shadow: none !important;
      }
    }

    .install-link {
      background: #28a745;
      
      &:hover {
        background: #218838;
      }
    }
    
    .install-help-link {
      background: #6c757d;
      
      &:hover {
        background: #5a6268;
      }
    }
  }
  
  #additional-info {
    background: var(--${PROJECT_PREFIX}-theme-bg-base) !important;
    line-height: 1.8;
    border: none !important;
    
    p {
      color: var(--${PROJECT_PREFIX}-theme-text-secondary) !important;
    }
  }
}
`
  }
}
